clear
cd "insert your local directory here"
capture mkdir out



***********************************************************
***********************************************************
*
* TABLE OF CONTENTS
*
* A) Experiment 1
*	 How do default setters specify defaults? 
*	 How do decision makers react to defaults? 
*
* B) Experiment 2
*	 Table 2
*	 Table 3
*	 Non-parametric tests
*
* C) Vignette Survey
*	 Figure 2
*	 Descriptives and tests	
*
* D) Online Appendix
*	 Table 4
*	 Table 5
*
************************************************************
************************************************************





************************************************************************
************************************************************************
****                A)     Experiment 1			                    ****
************************************************************************
************************************************************************


use Experiment1.dta, clear
log using "out/Experiment1.log", replace


**************************************
* How do default setters set defaults? 
**************************************

*Descriptives: default setting across treatment
keep if first_mover==0
bys treat: su defaulttrue

*Tests for treatment differences: Kendall's Tau, Mann-Whitney
preserve
collapse(mean) defaulttrue, by (treat mg)
ktau defaulttrue treat 
ranksum defaulttrue if  treat!=0, by(treat)
ranksum defaulttrue if  treat!=1, by(treat)
ranksum defaulttrue if  treat!=2, by(treat)
restore

*Are defaults in MIS informative? (one-sample Wilcoxon test)
preserve
collapse(mean) defaulttrue, by (treat mg)
signrank defaulttrue=.50 if treat==0
restore



**************************************
*How do decision makers react to defaults?
**************************************

*Descriptives: default adherence across treatment
bys treat: su followdefault

*Tests for treatment differences: Kendall's Tau, Mann-Whitney
preserve
collapse(mean) followdefault, by (treat mg)
ktau followdefault treat 
ranksum followdefault if  treat!=0, by(treat)
ranksum followdefault if  treat!=1, by(treat)
ranksum followdefault if  treat!=2, by(treat)
restore

*Descriptives: choice equals decision makers' own signal (Fn. 12) 
gen follow_ownsignal = 0
replace follow_ownsignal = 1 if signalblack_second == choiceBlack
bys treat: su follow_ownsignal if agentinfo>80



**************************************
*Figure 1, upper panel
**************************************

*Temp: figure labels
gen graphlabel = 3-treatment

graph bar (mean) followdefault,  over(graphlabel, relabel(1 "FUL" 2 "PAR" 3 "MIS")) over(agentinfo, relabel(1 "S50" 2 "S69" 3 "S77" 4 "S94" 5 "S100")) asyvars bar(1, bfcolor(gs11) blcolor(gs11)) bar(2, bfcolor(gs7) blcolor(gs7)) bar(3, bfcolor(black) blcolor(black)) ytitle(Fraction of decision makers accepting the default ) ylabel(0.5(.1)1) legend(cols(3)) exclude0 scheme(s1color) bargap(0)
graph display, xsize(15) ysize(10)
graph export "out\Figure1_upper.pdf", replace


**************************************
*Figure 1, bottom panel
**************************************
preserve
*Temp: empty bar for type S50
replace conflict=1 if agentinfo==50
replace followdefault = 0 if agentinfo==50 
collapse (mean) followdefault  if first_mover==0, by(agentinfo graphlabel conflict)
graph bar (mean) followdefault if conflict==1,  over(graphlabel, relabel(1 "FUL" 2 "PAR" 3 "MIS")) over(agentinfo, relabel(1 "S50" 2 "S69" 3 "S77" 4 "S94" 5 "S100")) asyvars bar(1, bfcolor(gs11) blcolor(gs11)) bar(2, bfcolor(gs7) blcolor(gs7)) bar(3, bfcolor(black) blcolor(black)) ytitle(Fraction of decision makers accepting the default ) ylabel(0(.1)1) legend(cols(3)) scheme(s1color) bargap(0)
graph display, xsize(15) ysize(10)
graph export out/Figure1_lower.pdf, replace
restore


**************************************
*Tests related to Figure 1
**************************************

*Default adherence between treatments: decicion makers with relatively better vs. worse private signals 
preserve
drop if conflict !=1
gen agentinfo_high = 0 
replace agentinfo_high = 1 if agentinfo >80 
 
collapse(mean) followdefault, by (treat mg agentinfo_high)
ktau followdefault treat if agentinfo_high==1
ktau followdefault treat if agentinfo_high==0

ranksum followdefault if  treat!=0 & agentinfo_high==1, by(treat)
ranksum followdefault if  treat!=1 & agentinfo_high==1, by(treat)
ranksum followdefault if  treat!=2 & agentinfo_high==1, by(treat)

ranksum followdefault if  treat!=0 & agentinfo_high==0, by(treat)
ranksum followdefault if  treat!=1 & agentinfo_high==0, by(treat)
ranksum followdefault if  treat!=2 & agentinfo_high==0, by(treat)
restore

*Default adherence within treatment: decicion makers with relatively better vs. worse private signals 
preserve
drop if conflict !=1
gen followdefault_info_low = followdefault if agentinfo==50|agentinfo==69|agentinfo==77
gen followdefault_info_high = followdefault if agentinfo==94|agentinfo==100
collapse(mean) followdefault_info_low followdefault_info_high, by (treat mg)
signrank followdefault_info_low=followdefault_info_high if treat==0 
signrank followdefault_info_low=followdefault_info_high if treat==1 
signrank followdefault_info_low=followdefault_info_high if treat==2 
restore


**************************************
*Differences in decision quality
**************************************

*Descriptives: actual frequency of correct choices vs. hypothetical frequency of correct choices when always following own signal

*MIS treatment
bys agentinfo: su choicecorrect signal_a_correct if treat==0 & first_mover==0

*PAR treatment
bys agentinfo: su choicecorrect signal_a_correct if treat==1 & first_mover==0

*FUL treatment
bys agentinfo: su choicecorrect signal_a_correct if treat==2 & first_mover==0



log close




************************************************************************
************************************************************************
****              B)       Experiment 2			                    ****
************************************************************************
************************************************************************

use Experiment2.dta, clear
log using "out/Experiment2.log", replace


*Temp variables
gen MIS_DEF = 1-advice
gen suggestionred = 1- suggestionblack
gen MIS_DEF_BlackSig = MIS_DEF*signalblack_first
gen MIS_DEF_BLACK = MIS_DEF*suggestionblack


**************************************
*Table 2
**************************************

reg defaulttrue MIS_DEF if first_mover==1, cluster(mg)
    outreg2 using out/Table2.xls, dec(3)   replace
reg defaulttrue  MIS_DEF age female abi math hhs GPS1 GPS2 donation  if first_mover ==1, cluster(mg)
    outreg2 using out/Table2.xls, dec(3)  append
reg defaulttrue MIS_DEF signalblack_first MIS_DEF_BlackSig if first_mover==1, cluster(mg)
    outreg2 using out/Table2.xls, dec(3)  append
	test MIS_DEF + MIS_DEF_BlackSig = 0
reg defaulttrue  MIS_DEF signalblack_first MIS_DEF_BlackSig age female abi math hhs GPS1 GPS2 donation  if first_mover ==1, cluster(mg)
    outreg2 using out/Table2.xls, dec(3)   append
reg suggestionred MIS_DEF if first_mover ==1, cluster(mg)
    outreg2 using out/Table2.xls, dec(3)  append
reg suggestionred  MIS_DEF age female abi math hhs GPS1 GPS2 donation if first_mover ==1, cluster(mg)
    outreg2 using out/Table2.xls, dec(3)  append


	
**************************************
*Table 3
**************************************

reg followdefault MIS_DEF if first_mover ==0, cluster(mg)
    outreg2 using out/Table3.xls, dec(3)  replace
reg followdefault  MIS_DEF age female abi math hhs GPS1 GPS2 donation  if first_mover ==0, cluster(mg)
    outreg2 using out/Table3.xls, dec(3)  append
reg followdefault MIS_DEF suggestionblack MIS_DEF_BLACK if first_mover ==0, cluster(mg)
    outreg2 using out/Table3.xls, dec(3)  append
	test MIS_DEF + MIS_DEF_BLACK=0
reg followdefault  MIS_DEF suggestionblack MIS_DEF_BLACK age female abi math hhs GPS1 GPS2 donation if first_mover ==0, cluster(mg)
    outreg2 using out/Table3.xls, dec(3)  append
reg followdefault MIS_DEF suggestionblack MIS_DEF_BLACK if first_mover ==0 & conflict==1, cluster(mg)
    outreg2 using out/Table3.xls, dec(3)  append
	test MIS_DEF + MIS_DEF_BLACK=0
reg followdefault  MIS_DEF suggestionblack MIS_DEF_BLACK age female abi math hhs GPS1 GPS2 donation if first_mover ==0 & conflict==1, cluster(mg)
    outreg2 using out/Table3.xls, dec(3)  append


**************************************
*Non-parametrics
**************************************

*First-mover behavior
preserve
collapse(mean)  defaulttrue, by (first_mover mg advice)
ranksum defaulttrue if first_mover ==1, by(advice)
restore

preserve
collapse(mean) defaulttrue, by (first_mover mg advice signalblack_first)
ranksum defaulttrue if first_mover ==1 & signalblack_first==1, by(advice)
ranksum defaulttrue if first_mover ==1 & signalblack_first==0, by(advice)
restore

preserve
collapse(mean) followdefault , by (first_mover  mg advice)
ranksum followdefault if first_mover ==0, by(advice)
restore


**************************************
*Type S50 (footnote 19)
**************************************

reg followdefault  MIS_DEF suggestionblack MIS_DEF_BLACK if first_mover ==0 & agentinfo == 50, cluster(mg)


log close





************************************************************************
************************************************************************
****                C)     Vignette Survey 	                        ****
************************************************************************
************************************************************************


use Vignette.dta, clear
log using "out/Vignette.log", replace


************************************************************************
****                     Vignette Survey 	                        ****
************************************************************************

*Drop participants with response duration < 2 minutes / without response duration record  
drop if duration<2


 
**************************************
*Descriptives: agreement to statements
**************************************

*It is a coincidence that XXX is the default option. 
tab LH_random
tab ADAC_random
tab Stadt_random

*The default was chosen since XXX thinks it is the best choice for the typical customers
tab LH_bene
tab ADAC_bene
tab Stadt_bene
tab Bank_bene
tab VZ_bene

*The default was chosen to maximize the profits of XXX 
tab LH_profit
tab ADAC_profit
tab Stadt_profit
tab Bank_profit
tab VZ_profit


**************************************
*Figure 2
**************************************

*define auxiliary variables
expand 5, gen(dupl)
gen scenario = .
sort id dupl
replace scenario = 1 if dupl==0
replace scenario =2 if scenario[_n-1]==1
replace scenario =3 if scenario[_n-1]==2
replace scenario =4 if scenario[_n-1]==3 & treat==1
replace scenario =5 if scenario[_n-1]==3 & treat==0
gen bene = .
replace bene = LH_bene if scenario ==1
replace bene = ADAC_bene if scenario ==2
replace bene = Stadt_bene if scenario ==3
replace bene = Bank_bene if scenario ==4
replace bene = VZ_bene if scenario ==5
gen profit = .
replace profit = LH_profit if scenario==1
replace profit = ADAC_profit if scenario==2
replace profit = Stadt_profit if scenario==3
replace profit = Bank_profit if scenario==4
replace profit = VZ_profit if scenario==5

gen random = .
replace random = LH_random if scenario==1
replace random = ADAC_random if scenario==2
replace random = Stadt_random if scenario==3

label define sce 1 "Airline" 2 "Car insurance" 3 "Public utility" 4 "Banks' assn." 5 "Consumer org."
label value  scenario sce

*Plot figure
graph hbar (count) if scenario<4, over(random) over(scenario) subtitle(Panel A: 'Defaults are a concidence') ytitle(Frequency (in percent)) bar(1, color(black)) bar(2, color(gs2)) bar(3, color(gs3)) bar(4, color(gs4)) bar(5, color(gs10)) bar(6, color(gs11)) bar(7, color(gs12)) bar(8, color(gs14)) legend(rows(1) region(lwidth(none)) stack size(small) order(1 "completely" "disagree" 2 "" 3 "" 4  "" 5  "" 6 "" 7 ""  8 "completely" "agree")) scheme(s1mono) percent stack asyvars
 graph export "out/Figure2_upper.pdf", replace

 
graph hbar (count), over(bene) over(scenario) subtitle(Panel B: 'Company thinks default is best for customers') ytitle(Frequency (in percent)) bar(1, color(black)) bar(2, color(gs2)) bar(3, color(gs3)) bar(4, color(gs4)) bar(5, color(gs10)) bar(6, color(gs11)) bar(7, color(gs12)) bar(8, color(gs14)) legend(rows(1) region(lwidth(none)) stack size(small) order(1 "completely" "disagree" 2 "" 3 "" 4  "" 5  "" 6 "" 7 ""  8 "completely" "agree")) scheme(s1mono) percent stack asyvars
 graph export out/Figure2_middle.pdf, replace

graph hbar (count), over(profit) over(scenario) subtitle(Panel C: 'Default was chosen to maximize company's profits') ytitle(Frequency (in percent)) bar(1, color(black)) bar(2, color(gs2)) bar(3, color(gs3)) bar(4, color(gs4)) bar(5, color(gs10)) bar(6, color(gs11)) bar(7, color(gs12)) bar(8, color(gs14)) legend(rows(1) region(lwidth(none)) stack size(small) order(1 "completely" "disagree" 2 "" 3 "" 4  "" 5  "" 6 "" 7 ""  8 "completely" "agree")) scheme(s1mono) percent stack asyvars
 graph export out/Figure2_bottom.pdf, replace


 

**************************************
*Differences across scenarios
**************************************

skilmack bene, id(id) repeated(scenario)
skilmack bene if scenario <5, id(id) repeated(scenario)
skilmack bene if scenario !=4, id(id) repeated(scenario)
skilmack profit , id(id) repeated(scenario)
skilmack profit if scenario <5, id(id) repeated(scenario)
skilmack profit if scenario !=4, id(id) repeated(scenario)

*treatment differences for Scenario 4 (retirement saving)
reg bene treat if scenario>3 
reg profit treat if scenario>3 


**************************************
*Treatment effects in expected default adherence
**************************************

use Vignette.dta, clear
*Drop participants with response duration < 2 minutes / without response duration record  
drop if duration<2

reg default_percent treatment	
reg default_percent treatment female age education car house born_in_DE fin_literacy

log close




************************************************************************
************************************************************************
****               D)      Online Appendix 	                        ****
************************************************************************
************************************************************************

log using "out/OnlineAppendix.log", replace

**************************************
*Table 4
**************************************

use "Experiment1.dta", clear

*generate auxiliary variables
gen defaulttrue_black = defaulttrue if first_mover & signalblack_first==1
egen defaulttrue_black_total = sum(defaulttrue_black) if first_mover, by(subjectid)
egen signalblack_total = sum(signalblack_first) if first_mover, by(subjectid)
gen defaulttrue_black_percent = defaulttrue_black_total / signalblack_total*100


*estimations for Table 4
reg defaulttrue_black_percent hhs if first_mover & treat==0 & period==50, cluster(mg)
 outreg2 using out/Table4.xls, dec(3)  replace
reg defaulttrue_black_percent crt math if first_mover & treat==0 & period==50, cluster(mg)
 outreg2 using out/Table4.xls, dec(3)  append
reg defaulttrue_black_percent hhs crt math if first_mover & treat==0 & period==50, cluster(mg)
 outreg2 using out/Table4.xls, dec(3)  append




******************************************
* Table 5
******************************************

use Vignette.dta, clear

*Drop participants with response duration < 2 minutes / without response duration record  
drop if duration<2

su age female born_in_DE house car fin_literacy duration 
tab edu 
tab employment 

log close